function Dictionary() {
    var items = {};

    this.has = function (key) {
        return key in items        // 验证key是否是items对象的属性
    };

    this.set = function(key,value){
        items[key] = value;
    }

    this.delete = function (key) {
        if(this.has(key)){
            delete items[key];
            return true;
        }
        return false
    }

    this.get = function (key) {
        return items[key] ? items[key]:undefined;
    }

    this.values = function () {
        var values = []
        for(var k in items){
            if(this.has(k)){
                values.push(items[k])
            }
        }
        return values
    }

    this.clear = function () {
        items = {}
    }

    this.keys = function () {
        return Object.keys(items)       // Object.keys会返回一个所有元素为字符串的数组
    }

    this.getItem = function () {
        return items
    }

    this.size = function () {
        return Object.keys(items).length
    }
}

var dictionary = new Dictionary();
dictionary.set("one","1111")
dictionary.set("two","2222")
dictionary.set("three","333")

console.log(dictionary.has("one"))
console.log(dictionary.has("1111"))
console.log(dictionary.size())
console.log(dictionary.keys())
console.log(dictionary.values())
console.log(dictionary.get('one'))